package com.hssy.wululuaplan.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Objects;
@Slf4j
@Component
public class ClearScheduled {

    /**
     * 每天凌晨清理本地缓存文件
     */
    @Scheduled(cron = "0 0 0 1/1 * ?")
    public void deleteMailExcel() {
        // 删除本地发送后剩余的资料
        File file = new File("d:/wululu/");
        int num = 0;
        for (File itemFile : Objects.requireNonNull(file.listFiles())) {
            itemFile.delete();
            log.info("【定时任务】正在清理本地缓存文件...  {}", ++num);
        }
        log.info("【定时任务】本地缓存文件清理完成");
    }
}
